package com.sdhs.projectschedule.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.sdhs.common.annotation.Log;
import com.sdhs.common.core.controller.BaseController;
import com.sdhs.common.core.domain.AjaxResult;
import com.sdhs.common.core.page.TableDataInfo;
import com.sdhs.common.enums.BusinessType;
import com.sdhs.common.utils.poi.ExcelUtil;
import com.sdhs.projectschedule.domain.GcProgressWeeklyReport;
import com.sdhs.projectschedule.service.IGcProgressWeeklyReportService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * 项目进度控制--周月报Controller
 *
 * @author andong
 * @date 2025-03-11
 */
@RestController
@RequestMapping("/progress/weekly")
public class GcProgressWeeklyReportController extends BaseController
{
    @Autowired
    private IGcProgressWeeklyReportService gcProgressWeeklyReportService;

    /**
     * 查询项目进度控制--周月报列表
     */
    @PreAuthorize("@ss.hasPermi('weekly:weekly:list')")
    @GetMapping("/list")
    public TableDataInfo list(GcProgressWeeklyReport gcProgressWeeklyReport)
    {
        startPage();
        List<GcProgressWeeklyReport> list = gcProgressWeeklyReportService.selectGcProgressWeeklyReportList(gcProgressWeeklyReport);
        return getDataTable(list);
    }

    /**
     * 导出项目进度控制--周月报列表
     */
    @PreAuthorize("@ss.hasPermi('weekly:weekly:export')")
    @Log(title = "项目进度控制--周月报", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GcProgressWeeklyReport gcProgressWeeklyReport)
    {
        List<GcProgressWeeklyReport> list = gcProgressWeeklyReportService.selectGcProgressWeeklyReportList(gcProgressWeeklyReport);
        ExcelUtil<GcProgressWeeklyReport> util = new ExcelUtil<GcProgressWeeklyReport>(GcProgressWeeklyReport.class);
        util.exportExcel(response, list, "项目进度控制--周月报数据");
    }

    /**
     * 获取项目进度控制--周月报详细信息
     */
    @PreAuthorize("@ss.hasPermi('weekly:weekly:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(gcProgressWeeklyReportService.selectGcProgressWeeklyReportById(id));
    }

    /**
     * 新增项目进度控制--周月报
     */
    @PreAuthorize("@ss.hasPermi('weekly:weekly:add')")
    @Log(title = "项目进度控制--周月报", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GcProgressWeeklyReport gcProgressWeeklyReport)
    {
        return toAjax(gcProgressWeeklyReportService.insertGcProgressWeeklyReport(gcProgressWeeklyReport));
    }

    /**
     * 修改项目进度控制--周月报
     */
    @PreAuthorize("@ss.hasPermi('weekly:weekly:edit')")
    @Log(title = "项目进度控制--周月报", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GcProgressWeeklyReport gcProgressWeeklyReport)
    {
        return toAjax(gcProgressWeeklyReportService.updateGcProgressWeeklyReport(gcProgressWeeklyReport));
    }


    /**
     * 逻辑删除项目进度控制--周月报
     */
    @PreAuthorize("@ss.hasPermi('weekly:weekly:remove')")
    @Log(title = "项目进度控制--周月报", businessType = BusinessType.DELETE)
	@DeleteMapping("/{id}")
    public AjaxResult delete(@PathVariable Long id)
    {
        return toAjax(gcProgressWeeklyReportService.deleteGcProgressWeeklyReportById(id));
    }
}
